import type { BaseController } from '@/controller/BaseAppliance/definition'
import type { OTAHelper } from '../settings/ota/helpers/types'
import { createOtaHelper } from '../settings/ota/helpers'
import { pick } from 'lodash'
import { useApplianceStore } from '@/store/appliance'

export function useInhouseOtaHelper(control: BaseController.Control): OTAHelper | null {
  if (control.store.isVirtualAppliance) return null

  const applianceStore = useApplianceStore()
  if (!applianceStore.current) return null

  return createOtaHelper({
    ...pick(applianceStore.current, ['brand', 'type', 'vib', 'haId']),
    scene: 'detail',
  })
}
